//
//  ZTFootVideoTableViewController.m
//  zhibo8
//
//  Created by zzt on 16/11/21.
//  Copyright © 2016年 zzt. All rights reserved.
//

#import "ZTFootVideoTableViewController.h"
static int i = 0;
static int j = 0;
@implementation ZTFootVideoTableViewController

- (NSString *)type{
    NSDate *currentDate = [NSDate date];//获取当前时间，日期
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    //只取年月日
    [dateFormatter setDateFormat:@"YYYYMMddhhmmss"];
    
    NSString *dateString = [dateFormatter stringFromDate:currentDate];
    return dateString;
    

}

- (NSString *)url{
    NSDate *currentDate = [NSDate date];//获取当前时间，日期
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    //只取年月日
    [dateFormatter setDateFormat:@"YYYY-MM-dd"];
    
    NSString *dateString = [dateFormatter stringFromDate:currentDate];
    NSString *date = [NSString stringWithFormat:@"http://m.zhibo8.cc/json/video/zuqiu/%@.json",dateString];
    return date;
    
//    NSString *date = @"http://m.zhibo8.cc/json/video/zuqiu/2016-11-23.json";
//    return date;

}

- (NSString *)more_type{
    
    i+=1;
    NSDate *currentDate =[NSDate date];//简书 FlyElephant
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    
    [formatter setDateFormat:@"yyyy"];
    NSInteger currentYear=[[formatter stringFromDate:currentDate] integerValue];
    [formatter setDateFormat:@"MM"];
    NSInteger currentMonth=[[formatter stringFromDate:currentDate]integerValue];
    [formatter setDateFormat:@"dd"];
    NSInteger currentDay=[[formatter stringFromDate:currentDate] integerValue];
    
    NSInteger yesterday = currentDay - i;
    
    if (yesterday == 0) {
        if((currentMonth-1)==1||(currentMonth-1)==3||(currentMonth-1)==5||(currentMonth-1)==7||(currentMonth-1)==8||(currentMonth-1)==10||(currentMonth-1)==12) {
            
            yesterday = 31;
            i = 0;
            currentMonth -= 1;
            
        }else {
            yesterday = 30;
            i = 0;
            currentMonth -= 1;
            
        }
    }
    
    if (currentMonth == 0) {
        currentMonth = 12;
        currentYear -= 1;
    }
    
    return [NSString stringWithFormat:@"%ld%02ld%02ld",(long)currentYear, (long)currentMonth,(long)yesterday];
}

- (NSString *)more_url{
    
    j++;
    NSDate *currentDate =[NSDate date];//简书 FlyElephant
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    
    [formatter setDateFormat:@"yyyy"];
    NSInteger currentYear=[[formatter stringFromDate:currentDate] integerValue];
    [formatter setDateFormat:@"MM"];
    NSInteger currentMonth=[[formatter stringFromDate:currentDate]integerValue];
    [formatter setDateFormat:@"dd"];
    NSInteger currentDay=[[formatter stringFromDate:currentDate] integerValue];
    
    NSInteger yesterday = currentDay - j;
    
    
    if (yesterday == 0) {
        if((currentMonth-1)==1||(currentMonth-1)==3||(currentMonth-1)==5||(currentMonth-1)==7||(currentMonth-1)==8||(currentMonth-1)==10||(currentMonth-1)==12) {
            
            yesterday = 31;
            j = 0;
            currentMonth -= 1;
            
        }else {
            yesterday = 30;
            j = 0;
            currentMonth -= 1;
            
        }
    }
    
    if (currentMonth == 0) {
        currentMonth = 12;
        currentYear -= 1;
    }
    
    return [NSString stringWithFormat:@"http://m.zhibo8.cc/json/video/zuqiu/%ld-%02ld-%02ld.json",(long)currentYear, (long)currentMonth,(long)yesterday];
    
}
@end
